<template>
    <div class="ff-recommend-submit">
        <present :get-data="getSubmitData" :has-head="false" :pagination="false" nodatatext="暂无提交款"></present>
    </div>
</template>

<script>
    import present from '@/views/recommend/childrenRoute/addOrReplace'
    export default {
        data() {
            return {}
        },
        components: {
            present
        },
        methods: {
            /**
             * 获取换款数据列表(业务组件,数据耦合性较强)
             * @param
             * cb: 回调函数,用户返回处理后的数据
            **/
            getSubmitData (cb) {
                this.$http({
                    url: '/api/SelPro/GetReqStyList',
                    method: 'post',
                    data: {
                        strId: this.$store.state.userId
                    }
                }).then(res => {
                    let data = res.data;
                    if(data.code === 1) {
                        let arr = data.data.map(obj => {
                            let imgList = obj.img? JSON.parse(obj.img) : [];
                            return Object.assign({
                                disabled: true,//是否禁用
                                ecode: obj.styCode,//款号
                                name: obj.styName,//款名称
                                imageUrl: imgList[0].URL,//商品主图
                                volume: obj.qtyRetail7D,//销量
                                ranking: obj.itmSuggestReasonName,//排名
                                inform: `${obj.lenName},${obj.slveLenName}`,//衣长,袖长
                                presentPrice: obj.stdPrice === obj.retailPrice || obj.retailPrice === 0? obj.stdPrice : obj.retailPrice,//最终显示价格
                                showFocus: true,//显示收藏
                                focus: obj.isAtten === 1? true : false,//是否已收藏
                                focusSum: obj.attention,//收藏数量
                                checked: false,//是否选中
                                imgList: imgList.map(img => {
                                    return {
                                        src: img.URL,
                                        active: false
                                    }
                                }),//小图集合
                            }, obj)
                        })
                        cb(arr);
                    }else {
                        cb([]);
                    }
                }).catch(() => {
                    cb([]);
                })
            },
        }
    }
</script>

<style type="text/less" lang="less">
.ff-recommend-submit {
    width: 100%;
    margin-top: 10px;
}
</style>